package vcp.client.GUI.mvc.model;

import vcp.client.forms.ReportSummaryForm;
import vcp.client.interfaces.IObservable;
import vcp.client.reports.ReportAbstract;
import vcp.client.request.InformationRetrieveRequest;
import vcp.entity.Worker;

public class UIInfoRetrieveModel extends UIAbstractModel
{
	private Worker CEO;

	public Worker getCEO ()
	{
		return this.CEO;
	}

	public void setCEO ( Worker cEO )
	{
		this.CEO = cEO;
	}

	private ReportAbstract report;

	public ReportAbstract getReport ()
	{
		return this.report;
	}

	public UIInfoRetrieveModel ( IObservable model )
	{
		super(model);
	}

	// ****************************************************************************************************************************
	// Public methods
	// ****************************************************************************************************************************

	public void retrieveInforamtion ( ReportSummaryForm form )
	{
		InformationRetrieveRequest request = new InformationRetrieveRequest(form);
		this.sendRequest(request, true);
	}

	// ****************************************************************************************************************************
	// UIAbstractModel methods
	// ****************************************************************************************************************************
	@Override
	public void clearModel ()
	{
		this.CEO = null;
	}

	@Override
	public void update ( Object data )
	{
		// received new report
		if ( data instanceof ReportAbstract )
		{
			this.report = (ReportAbstract) data;
			// notify controllerDelegate on data change
			this.controllerDelegate.updateControllerDelegateWithData(data);
		}

		this.controllerDelegate.loadingStop();
	}

}
